<template>
	<view class="homePage">
		<view class="comm">
			<classify @Child="handleChildData" :postsAllTitle="title" :list="postsAllText" :flag="true" :total="8" :count="6"></classify>
		</view>
		<!-- <view class="homePage_leaderboard">
			<view class="homePage_leaderboard_text">赞助月榜</view>
			<view style="display: flex; width: 70%;">
				<view class="homePage_leaderboard_user" v-for="(item, index) in 3" :key="index">
					<view class="homePage_leaderboard_user_headImg">
						<view :class="[
		            'custom-icon', 
		            index === 0 ? 'custom-icon-numberOne' : 
		            index === 1 ? 'custom-icon-numberTwo' : 
		            'custom-icon-numberThree'
		          ]" :style="{ color: index === 0 ? '#ffdc49' : (index === 1 ? '#c7d2eb' : '#dea781') }">
						</view>
						<view class="headImg">
							<image src="/static/2.jpg" mode="widthFix" />
						</view>
					</view>
					<view class="homePage_leaderboard_user_name">发点用户</view>
				</view>
			</view>
		</view> -->
		<view class="homePage_dynamicLiist">
			<dynamicList :list="list"></dynamicList>
			<u-loadmore :status="status" @loadmore="getDynamicList" />
		</view>
	</view>
</template>

<script>
	export default {
		name: "homePage",
		props:{
			userId:{
				type:Number,
				required: true
			}
		},
		data() {
			return {
				list: [],
				title: '全部分类',
				cateId:'',
				postsAllText: [],
				status: 'more' // 加载状态: 'more', 'loading', 'noMore'
			}
		},
		mounted() {
			this.getDynamicList();
		    this.getCateList();
		   
		},
		methods: {
			// 获取动态分类列表的id
			handleChildData(data) {
				this.cateId=data;
				console.log("父", data)
				console.log("this.cateId", this.cateId)
				this.getDynamicList()
			},
			setCateId(data){
				console.log("父",data);
				
			},
			// 获取动态分类列表
			getCateList(){
				this.$api.getCateList().then(res => {
				    this.postsAllText = res.data;
				})
			},
			// 获取动态列表
			getDynamicList() {
				// 当前api少了分类列表的参数this.cateId
				this.$api.getDynamicList({
					cate_id:this.cateId,
					page: '',
					limit: '',
					uuid:this.userId
				}).then(res => {
					console.log("res", res);
					this.list = res.data.data;
				})
			},
		}
	}
</script>

<style scoped lang="scss">
	.homePage {
		width: 100%;
	}

	.comm {
		width: 90%;
		margin: auto;
		margin-bottom: 40rpx;
		background: #ffffff;
		border-radius: 20rpx;
	}

	.homePage_leaderboard {
		width: 90%;
		// height: 200rpx;
		margin: auto;
		// border: 1px red solid;
		display: flex;
		align-items: center;
		background: #fff;
		margin-top: 20px;
		border-radius: 10px;

		// justify-content: space-between;
		.homePage_leaderboard_text {
			width: 30%;
			font-weight: bold;
			font-size: 40rpx;
			line-height: 200rpx;
			text-align: center;
		}

		.homePage_leaderboard_user {
			width: 34%;
			// border: 1px #000 solid;

			.homePage_leaderboard_user_headImg {
				width: 100%;
				// border: 1px red solid;
				display: flex;
				flex-direction: column;
				align-items: center;

				.huangguan {
					width: 30%;
					position: relative;
					top: 20rpx;
					left: 20%;
				}

				.custom-icon {
					width: 130%;
					height: 50rpx;
					font-size: 65rpx;
					display: flex;
					justify-content: flex-end;
				}



				.headImg {
					width: 100%;
					border-radius: 100rpx;
					display: flex;
					justify-content: center;
					align-items: center;
				}

				// #ifdef H5
				.custom-icon {
					width: 80%;
					height: 40rpx;
					font-size: 55rpx;
					display: flex;
					justify-content: flex-end;
				}

				.headImg {
					width: 45%;
				}

				// #endif

				image {
					width: 70%;
					border-radius: 100rpx;

				}
			}

			.homePage_leaderboard_user_name {
				text-align: center;
				overflow: hidden;
				text-overflow: ellipsis;
				white-space: nowrap;
			}
		}
	}
</style>